package com.wx.fresh.user.service;

import com.wx.fresh.common.pojo.CUser;
import com.wx.fresh.user.api.UserFeignClient;
import com.wx.fresh.user.dto.PlatformUserDto;
import com.wx.fresh.user.mapper.CustomUserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author Dshzs月
 * @version 1.0.0
 * @ClassName CustomUserServiceImpl.java
 * @Description TODO
 * @createTime 2022年04月27日 10:35:00
 */
@RequestMapping("/user")
@RestController
public class UserFeignClientImpl implements UserFeignClient {


    @Autowired
    private CustomUserMapper customUserMapper;

    /**
     * 平台查询C端用户列表
     */
    @Override
    @GetMapping("/platformFindAll")
    public List<CUser> FindAll(PlatformUserDto platformUserDto) {
        CUser user = new CUser();
        BeanUtils.copyProperties(platformUserDto, user);
        List<CUser> list = customUserMapper.findAll(user);
        return list;
    }

    /**
     * 平台修改C端用户列表
     */
    @Override
    @PostMapping("/platformEdit")
    public int Edit(PlatformUserDto platformUserDto) {
        CUser user = new CUser();
        BeanUtils.copyProperties(platformUserDto, user);
        return customUserMapper.Edit(user);
    }

    /**
     * 平台查询个体C端用户列表
     */
    @Override
    @GetMapping("/platformFindById")
    public PlatformUserDto FindById(Long id) {
        CUser cUser = customUserMapper.FindById(id);
        PlatformUserDto platformUserDto = new PlatformUserDto();
        BeanUtils.copyProperties(cUser, platformUserDto);
        return platformUserDto;
    }

    /**
     * 删除用户
     */
    @Override
    @DeleteMapping("/platformDelete")
    public int Delete(Long id) {
        return customUserMapper.delete(id);
    }


}
